<template>
  <div>
    <swiper :options="swiperOption">
      <!-- 内容 -->
      
      <swiper-slide v-for="(page,index) in pages" :key="index">
        <router-link class="icon_box" 
          v-for="item in page" :key="item.id"
          :to="item.path">
          <img :src="item.image_url" alt>
          <span>{{item.icon_text}}</span>
        </router-link>
      </swiper-slide>
      <!-- 圆点控制 -->
      <!-- <div class="swiper-pagination" slot="pagination"></div> -->
    </swiper>
  </div>
</template>

<script>
export default {
  name: "HomeSwiper",
  props: {
    list: Array
  },
  data: function() {
    return {
      swiperOption: {
        pagination: {
          el: ".swiper-pagination"
        }
      }
    };
  },
  computed: {
    //计算属性
    pages: function() {
      //求页数
      const pages = [];
      this.list.forEach((item, index) => {
        const page = Math.floor(index / 10); //floor是向下取整,求具体页码
        if (!pages[page]) {
          pages[page] = [];
        }
        pages[page].push(item);
      });
      return pages;                                                      
    }
  }
};
</script>

<style scoped>
.swiper-slide img {
  width: 100%;
}
.icon_box {
  width: 20%;
  height: 81px;
  float: left;
}
.icon_box span {
  display: block;
}
.icon_box img {
  width: 0.8rem;
  margin-top: 0.32rem;
}
.images {
  font-size: 0.7rem;
  color: rgb(250, 142, 18);
}
.swiper-container {
  padding-bottom: 0.4rem;
  border-bottom: 0.23rem solid #f0efed;
}
.swiper-container-horizontal {
  bottom: 0px;
}
.swiper-container-horizontal {
  bottom: 0;
}
</style>
